const jwt=require('jsonwebtoken')

const secretKey='21308dsohfsih9q489'

function generatorTaken(e){
    const token=jwt.sign(e,secretKey,{
        expiresIn:600
    })
    return token
}
function verifyToken (req,res,next){
    const {token}=req.cookies
    jwt.verify(token,secretKey,(err,result)=>{
        if(err){
            res.redirect('/loginPage')
        }else{
            next()
        }
    })
}

module.exports={
    generatorTaken,
    verifyToken
}